package org.example.stockdemo.job;

import lombok.extern.slf4j.Slf4j;
import org.example.stockdemo.dto.StockMonitorDTO;
import org.example.stockdemo.entity.StockIndustryRank;
import org.example.stockdemo.entity.StockMonitor;
import org.example.stockdemo.entity.StockRank;
import org.example.stockdemo.service.StockIndustryRankService;
import org.example.stockdemo.service.StockMonitorService;
import org.example.stockdemo.service.StockRankService;
import org.example.stockdemo.service.TencentStockService;
import org.example.stockdemo.util.BeanExtUtil;
import org.example.stockdemo.util.CacheUtil;
import org.example.stockdemo.util.StockUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author :Mr.zhou
 * @description: 初始化数据
 * @create date: 2025/10/24 22:43
 */
@Slf4j
@Service
public class StockSyncJob {

    @Autowired
    private TencentStockService tencentStockService;
    @Autowired
    private StockRankService stockRankService;
    @Autowired
    private StockIndustryRankService industryRankService;
    @Autowired
    private StockMonitorService stockMonitorService;


    /**
     * 初始化股票数据
     */
    @Scheduled(cron = "1 25 9 * * ?")
    public void initStockData() {
        try {
            List<StockMonitor> list = stockMonitorService.list();
            for (StockMonitor stockMonitor : list) {
                StockMonitorDTO dto = BeanExtUtil.copyTo(stockMonitor, StockMonitorDTO.class);
                stockMonitorService.fillPrice(dto);
                Thread.sleep(2000);
            }
        } catch (InterruptedException e) {
            log.error("初始化股票数据失败", e);
        }

    }

    /**
     * 同步今日数据
     */
//    @Scheduled(cron = "1 0 15 * * ?")
    public void syncStockData() {

    }

}